package com.hz.house.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ToolsMapper {
    @Select("SELECT fd_id FROM building")
    List<Integer> getAllBuildingId();

    @Update("UPDATE building b SET fd_comments =#{count} WHERE fd_id=#{buildingId}")
    void updateBuildingComments(@Param("buildingId") Integer buildingId, @Param("count") int count);

    @Select("SELECT fd_id FROM building_comment b WHERE b.fd_buildingId=#{buildingId} AND fd_state='publish'")
    List<Integer> selectBuildingCommentCount(@Param("buildingId") Integer buildingId);

    @Select("SELECT COUNT(*) FROM building_comment_reply WHERE comId=#{commId}")
    Integer selectBuildingCommentReplyCount(@Param("commId") Integer commId);

    @Select("SELECT COUNT(*) FROM building_comment_reply WHERE comId IN (${commIds})")
    Integer selectBuildingCommentReplyCountByIds(@Param("commIds") String commIds);
}
